/**
 * Sample Jiggy Application
 * @author Martin Kleppe <kleppe@ubilabs.net>
 * @see http://code.google.com/p/jiggytype/
 */
include("scripts/jiggytype.js");

var application = {
	initialize: function(){
		this.window = new ui.Window();
		this.scroller = new ui.Scroller({
			width: this.window.width,
			height: this.window.height * 2
		});
		this.window.set(this.scroller);
		this.text = new ui.TextLabel({
			x: 20, y: 150,
			width: 280,	height: 360,
			text: "Lorem ipsum dolor sit amet.",
			font: "Courier New",
			wrap: true
		});
		this.image = new ui.ImageView("images/Background.png");
		this.scroller.add(this.image, this.text);
		this.test();
	},
	test: function(){
		var Person = Class.create({
			initialize: function(name){
				this.name = name;
			},
			say: function(message){
				return this.name + ': ' + message;
			}
		});
		var Pirate = Class.create(Person, {
			say: function($super, message){
				return $super(message) + ', yarr!';
			}
		});
		var jack = new Person("The Jack");
		var john = new Pirate("Long John");
		$A([jack, john]).each(function(guy){
			var message = guy.say("Ahoy World");
			log(message);
			this.text.add(message);
		}.bind(this));
		var template = new Template("#{who} rocks!");
		this.text.add(template.evaluate({
			who: "Prototype"
		}));
	}
};

application.initialize();